<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>查询空床位</title>
    <script src="http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.8.0.js"></script>
</head>
<body>
<div id="result"></div>
<br />
<div id="result2"></div>

</body>
<script type="text/javascript">
    $(document).ready(function () {
        var token = localStorage.getItem("token")
        $.ajax({
            type: 'get',
            url: 'http://localhost:8091/list',
            contentType: 'application/x-www-form-urlencoded; charset=UTF-8',
            dataType: 'json',
            data: {token},
            success: function (data){
                console.log(data)
                if(data.status == 1){
                    $("#result").html("")
                    for(var i = 0; i < data.data.length; i++){
                        $("#result").append("楼号："+data.data[i].buildingName)
                        if(data.data[i].gender == "0"){
                            $("#result").append(",  性别：男")
                        }else{
                            $("#result").append(",  性别：女")
                        }
                        $("#result").append(",  房间空床位数量："+data.data[i].freeBeds)
                        $("#result").append(",  该类型房间数量："+data.data[i].num)
                        $("#result").append("<br />")
                    }
                }

            },
            error:function (){
                alert("参数错误")
            }
        })

    })
</script>
</html>